package qiu.controll;

import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

import qiu.tuil.HttpHtml;

public class Spider {
	private String baseurl;
	private String encoding;
	private List<String>qiu_list;
	private String regx;
	private Pattern pattern;
	private HttpHtml http;
	public Spider()
	{
		//1?s=4552828&slow"";
		baseurl="http://www.qiushibaike.com/month/page/";
		encoding="utf-8";
		qiu_list=new ArrayList<String>();
		http=new HttpHtml();
		regx="<div class=\"content\"[^>]+>(.*?)</div>";
		pattern=Pattern.compile(regx,Pattern.MULTILINE|Pattern.DOTALL);
	}
	public List<String>getQiu(int pageindex)
	{
		String url=baseurl+pageindex+"?s=4552828&slow";
		String html=http.getHtml(url, encoding);
		Matcher m=pattern.matcher(html);
		qiu_list.clear();
		while(m.find())
		{
			String msg=m.group(1);
			qiu_list.add(msg);
		}
		return qiu_list;
	}
}
